<template>
	<view>
		<u-navbar
			title="通知详情"
			leftText="返回"
			bgColor="#ffffff"
			@leftClick="leftClick"
			:autoBack="false"
		>
		</u-navbar>
		
		<view style="margin-top: 100px;padding: 18px;">
			<view style="font-weight: 600;font-size: 40rpx;">{{noticeInfo.title}}</view>
			
			<view style="display: flex;flex-direction: row;margin-top: 9px;">
				<view style="color: cornflowerblue;">{{noticeInfo.author}}</view>
				<view style="margin-left: 10px;">{{noticeInfo.createTime}}</view>
			</view>
			
			<view style="margin-top: 20px;">
				<u-parse :content="noticeInfo.content"></u-parse><br><br><br>
			</view>
		</view>
	</view>
</template>

<script>
import { getNoticeIdApi } from '../../../utils/homePage';
	export default{
		data(){
			return{
				noticeInfo: {}
			}
		},
		methods:{
			leftClick(){
				// #ifdef H5
				const pages = getCurrentPages()
				if (pages.length > 1) {
					uni.navigateBack(1)
					return;
				}
				//使用vue-router返回上一级
				let a = this.$router.go(-1)
				if (a == undefined) {
					//重新定向跳转页面
					uni.reLaunch({
						url: '/pages/view/homepage/homepage'    
					})   
				}
				return;
				// #endif
				uni.navigateBack(1)
			},
			formatDate(time){
			  let nyr = time.slice(0, 10)
			  let sfm = time.slice(11,19)
					
			  let newTime = nyr + ' ' + sfm
					
			  return newTime;
			},
			
		},
		onLoad: async function(option) {
			console.log(option.id)
			const res = await getNoticeIdApi(option.id)
			if(res.code == 0){
				this.noticeInfo = res.data
				this.noticeInfo.createTime = this.formatDate(this.noticeInfo.createTime)
				console.log(res)
			}
		}
		
	}
</script>

<style scoped>
	
</style>